package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author evan0213
 * @description 超前点播模版计费详情
 */
@Data
@Entity
@Table(name = "advance_sale")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdvanceSale {

	/**
	 * <b>Fields</b> id : 主键
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ADVANCE_SALE_SEQ")
	@SequenceGenerator(name = "ADVANCE_SALE_SEQ", allocationSize = 1, sequenceName = "ADVANCE_SALE_SEQ")
	private Long id;

	/**
	 * <b>Fields</b> modelId : 模式ID
	 */
	@Column(name = "model_id")
	private Long modelId;

	/**
	 * <b>Fields</b> payMethod : 支付方式   咪咕一级支付  miguGROUP  苹果支付  applePAY  通看券 movieTICKET
	 */
	@Column(name = "pay_method")
	private String payMethod;

	/**
	 * <b>Fields</b> payCode : 支付代码 咪咕一级支付: MIGU_GROUP_V3_PAY, 苹果支付: APPLE_PAY, 通看券: CMVIDEO_TICKET_PAY
	 */
	@Column(name = "pay_code")
	private String payCode;

	/**
	 * <b>Fields</b> actualPrice : 真实价格
	 */
	@Column(name = "actual_price")
	private String actualPrice;

	/**
	 * <b>Fields</b> originalPrice : 最初价格
	 */
	@Column(name = "original_price")
	private String originalPrice;

	/**
	 * <b>Fields</b> unit : 单位 人民币分:CENT,通看券张数:CENT
	 */
	@Column(name = "unit")
	private String unit;

	/**
	 * <b>Fields</b> feePoint : 苹果、话费、谷歌时，该字段不可为空
	 */
	@Column(name = "fee_point")
	private String feePoint;

	/**
	 * <b>Fields</b> spCode : 话费支付方式时，该字段不可为空
	 */
	@Column(name = "sp_code")
	private String spCode;

	/**
	 * <b>Fields</b> prdId : 话费支付方式时，该字段不可为空
	 */
	@Column(name = "prd_id")
	private String prdId;

	/**
	 * <b>Fields</b> remarks : 备注
	 */
	@Column(name = "remarks")
	private Integer remarks;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@Column(name = "created_time")
	private String createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@Column(name = "updated_time")
	private String updatedTime;

	/**
	 * <b>Fields</b> del : 删除列
	 */
	@Column(name = "del")
	private Integer del;

	public static void putTimeAndUser(AdvanceSale advanceSale) {
		if (advanceSale.id == null) {
			advanceSale.setCreatedBy(CurrentUser.currUserName());
			advanceSale.setCreatedTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
		}
		advanceSale.setUpdatedBy(CurrentUser.currUserName());
		advanceSale.setUpdatedTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
	}
}
